<?php
/**
 * Created by PhpStorm.
 * User: Panjing
 * Date: 2021/1/3
 * Time: 10:55
 */
namespace app\publicuser;


use app\admin\model\Jianmatchfail;
use app\admin\model\Jianxianphonefail;
use app\admin\model\Jinggangshanphonefail;
use app\admin\model\Jinggangshanvcodefail;
use app\admin\model\Jishuiphonefail;
use app\admin\model\Jizhoumatchfail;
use app\admin\model\Jizhouxianphonefail;
use app\admin\model\Qingyuanmatchfail;
use app\admin\model\Qingyuanphonefail;
use app\admin\model\Suichuanphone;
use app\admin\model\Suichuanphonefail;
use app\admin\model\Suichuanvcodefail;
use app\admin\model\Taihephonefail;
use app\admin\model\Taihevcodefail;
use app\admin\model\Yongfengphone;
use app\admin\model\Yongfengphonefail;
use app\admin\model\Yongfengvcodefail;
use app\admin\model\Yongxinphonefail;
use app\admin\model\Yongxinvcodefail;
use app\utils\TimeUtils;
use fast\Http;
use think\Config;
use think\Log;
use think\Model;

class PublicTable
{

    /*
   * 永丰营销码不对记表
   */
    public static function CreateYongfengVcodeFail($tel,$vcode)
    {
        $yongfeng = new Yongfengvcodefail();
        $yongfeng->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'vcode'=>$vcode,
        ]);
        $yongfeng->save();
    }

    /*
     * 永丰归属地不对记表
     */
    public static function Yongfengchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $yongfeng = new Yongfengphonefail();
                $yongfeng->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $yongfeng->save();
                return 0;
            }
        }else{
            return 0;
        }
    }


    /*
    * 井冈山营销码不对记表
    */
    public static function CreateJingGangShanVcodeFail($tel,$vcode)
    {
        $jinggangshan = new Jinggangshanvcodefail();
        $jinggangshan->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'vcode'=>$vcode,
        ]);
        $jinggangshan->save();
    }

    /*
     * 井冈山归属地不对记表
     */
    public static function jinggangshanchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $jinggangshan = new Jinggangshanphonefail();
                $jinggangshan->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $jinggangshan->save();
                return 0;
            }
        }else{
            return 0;
        }
    }



    /*
    * 遂川营销码不对记表
    */
    public static function CreateSuiChuanVcodeFail($tel,$vcode)
    {
        $suichuan = new Suichuanvcodefail();
        $suichuan->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'vcode'=>$vcode,
        ]);
        $suichuan->save();
    }

    /*
     * 遂川归属地不对记表
     */
    public static function SuiChuanchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $suichuan = new Suichuanphonefail();
                $suichuan->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $suichuan->save();
                return 0;
            }
        }else{
            return 0;
        }
    }


    /*
     * 永新营销码不对记表
     */
    public static function CreateYongxinVcodeFail($tel,$vcode)
    {
        $yongxin = new Yongxinvcodefail();
        $yongxin->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'vcode'=>$vcode,
        ]);
        $yongxin->save();
    }

    /*
     * 永新归属地不对记表
     */
    public static function yongxinchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $yongxin = new Yongxinphonefail();
                $yongxin->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $yongxin->save();
                return 0;
            }
        }else{
            return 0;
        }
    }


    /*
         * 泰和营销码不对记表
         */
    public static function CreateVcodeFail($tel,$vcode)
    {
        $taihe = new Taihevcodefail();
        $taihe->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'vcode'=>$vcode,
        ]);
        $taihe->save();
    }



    /*
     * 泰和归属地不对记表
     */
    public static function taihechongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $taihe = new Taihephonefail();
                $taihe->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $taihe->save();
                return 0;
            }
        }else{
            return 0;
        }
    }



    /*
     * 吉水归属地不对记表
     */
    public static function jishuichongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $jishui = new Jishuiphonefail();
                $jishui->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $jishui->save();
                return 0;
            }
        }else{
            return 0;
        }
    }

    /*
    * 吉安县归属地不对记表
    */
    public static function jianxianchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $jianxian = new Jianxianphonefail();
                $jianxian->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $jianxian->save();
                return 0;
            }
        }else{
            return 0;
        }
    }

    /*
   * 吉州区归属地不对记表
   */
    public static function Jizhouchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $jianxian = new Jizhouxianphonefail();
                $jianxian->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $jianxian->save();
                return 0;
            }
        }else{
            return 0;
        }
    }


    /*
  * 青原归属地不对记表
  */
    public static function Qingyuanchongzhitest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                $qingyuan = new Qingyuanphonefail();
                $qingyuan->data([
                    'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
                    'tel' => $tel,
                    'area'=>$resultjson->city,
                ]);
                $qingyuan->save();
                return 0;
            }
        }else{
            return 0;
        }
    }


    /*
   * 已在别的地方充值信息
   */
    public static function jianmatchfail($tel,$areaorigin,$area)
    {
        $jianmatch = new Jianmatchfail();
        $jianmatch->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'area'=>$area,
            'areaorigin'=>$areaorigin,
        ]);
        $jianmatch->save();
    }


    /*
  * 吉州已在别的地方充值信息
  */
    public static function jizhoumatchfail($tel,$areaorigin,$area)
    {
        $jizhoumatch = new Jizhoumatchfail();
        $jizhoumatch->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'area'=>$area,
            'areaorigin'=>$areaorigin,
        ]);
        $jizhoumatch->save();
    }


    /*
 * 青原已在别的地方充值信息
 */
    public static function Qingyuanmatchfail($tel,$areaorigin,$area)
    {
        $qingyuanmatch = new Qingyuanmatchfail();
        $qingyuanmatch->data([
            'createtime' => TimeUtils::getTimeStamp('YmdHisu'),
            'tel' => $tel,
            'area'=>$area,
            'areaorigin'=>$areaorigin,
        ]);
        $qingyuanmatch->save();
    }
}